package com.wangzhenyu.learn.test.android_.fragmentViewModel

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.wangzhenyu.learn.databinding.TestFragmentListBinding
import com.wangzhenyu.common.base.BaseVBFragment
import com.wangzhenyu.learn.test.android_.adapter_.FragmentForClick
import com.wangzhenyu.learn.test.android_.adapter_.SimpleListAdapter

class TestListFragment : BaseVBFragment<TestFragmentListBinding>() {

    override fun getBinding(
        inflater: LayoutInflater,
        container: ViewGroup?
    ) = TestFragmentListBinding.inflate(inflater, container, false)

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        val dataList = arguments?.getStringArrayList("list") ?: listOf<String>()

        binding?.apply {
            recyclerView.layoutManager = LinearLayoutManager(requireContext())
            recyclerView.adapter =
                SimpleListAdapter(dataList, requireActivity() as FragmentForClick)
        }

    }

}